package cqrtplm.vo.query;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class AdvancedQueryConfig {
    private String mainTable;
    private Map<String, String> tableAliases;
    private Map<String, String> fieldMappings;

    public AdvancedQueryConfig() {
        this.tableAliases = new HashMap<>();
        this.fieldMappings = new HashMap<>();
    }

    public AdvancedQueryConfig(String mainTable) {
        this();
        this.mainTable = mainTable;
    }

    public void addTableAlias(String tableName, String alias) {
        tableAliases.put(tableName, alias);
    }

    public void addFieldMapping(String frontendField, String dbField) {
        fieldMappings.put(frontendField, dbField);
    }

    public String getDbField(String frontendField) {
        return fieldMappings.getOrDefault(frontendField, frontendField);
    }
}
